package com.colorful.insuranceproject.adapter;

import android.content.Context;
import android.support.annotation.NonNull;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.colorful.insuranceproject.R;
import com.lovely3x.common.adapter.BaseViewHolder;
import com.lovely3x.common.adapter.ListAdapter;

import java.util.List;

import butterknife.Bind;

/**
 * Created by handsome-Bob on 2017/10/27.
 * <p>
 * 城市列表的适配器
 */
public class CityListAdapter extends ListAdapter<CityListBean> {

    public CityListAdapter(List<CityListBean> datas, Context context) {
        super(datas, context);
    }

    @NonNull
    @Override
    public BaseViewHolder createViewHolder(int position, ViewGroup parent) {
        return new ViewHolder(getLayoutInflater().inflate(R.layout.item_city, parent, false));
    }

    @Override
    public void handleData(int position, @NonNull BaseViewHolder holder) {
        ViewHolder viewHolder = (ViewHolder) holder;
        CityListBean bean = datas.get(position);
        viewHolder.tvCity.setText(bean.getAreaName());
    }

    class ViewHolder extends BaseViewHolder {

        @Bind(R.id.tv_city)
        TextView tvCity;

        public ViewHolder(View rootView) {
            super(rootView);
        }
    }
}
